package com.lilicould.controller;

import com.lilicould.service.ContractService;
import com.lilicould.service.impl.ContractServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/contract/delete")
public class ContractDeleteController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String contractId = req.getParameter("contractId");
        ContractService contractService = new ContractServiceImpl();
        boolean result = contractService.deleteContract(contractId);
        if (result) {
            req.setAttribute("success", "删除成功");
            req.getRequestDispatcher("/page/success.jsp").forward(req, resp);
        }else {
            req.setAttribute("error", "删除失败");
            req.getRequestDispatcher("/page/err.jsp").forward(req, resp);
        }
    }
}
